# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: mgushee

pkgname=djvulibre
pkgver=3.5.28
pkgrel=5
pkgdesc='Library and utilities to create, manipulate and view DjVu (déjà vu) documents'
arch=('loong64' 'x86_64')
url='https://djvu.sourceforge.net/'
license=('GPL2')
depends=('bash' 'gcc-libs' 'glibc' 'hicolor-icon-theme' 'libjpeg-turbo' 'libtiff')
source=("https://downloads.sourceforge.net/djvu/$pkgname-$pkgver.tar.gz"
        'djvulibre-check-image-size.patch'
        'djvulibre-check-input-pool.patch'
        'djvulibre-djvuport-stack-overflow.patch'
        'djvulibre-integer-overflow.patch'
        'djvulibre-out-of-bound-write-2.patch'
        'djvulibre-unsigned-short-overflow.patch')
sha256sums=('fcd009ea7654fde5a83600eb80757bd3a76998e47d13c66b54c8db849f8f2edc'
            '5cd3bdedc9ba82af541e1fc0bb6fabdc77c7fc43ee6bd15f9c7cca9d39d53c82'
            'd938cb05ac37b2f3f9602de6d148307e4164ee8a6f89fb6d81d5ed100fbc368b'
            '73e476cdb8af46bf94b208b9170679aaba165d54247d435e6a58e874ae85109c'
            '9e6d8b94d922ba382702ec4f878c06293eb546827e40a7de5221cb21c52d3d23'
            'bfc2c89b86d1ab60b4fc8f48270c178269b619fee20dfeeee37ab08a1fda7432'
            '7ea0926757adaaff61b5622b2ee88d4af55fec5235183828337005852118f97f')

prepare() {
  cd $pkgname-$pkgver
  # Security fixes from Fedora
  for _patch in ../djvulibre-*.patch; do
    patch -Np1 -i $_patch
  done
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
}
